<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class LoginProcess extends CI_Controller {
function __construct()
    {
        parent::__construct();
    	$this->load->library('session');
		$this->load->helper('url');

	}

	
	function loginpro()
			{
			$this->session->unset_userdata('user');
		if($this->session->userdata("user")==false)
			{
				$name=$this->input->get_post("login_id");
				$pw=$this->input->get_post("login_pwd");
				if($name&&$pw)
					{
							$this->load->model("modlogin");
							$rows=$this->modlogin->db_auth_login($name,$pw);
							
							if(count($rows)>0)
							{
	
								if(count($rows)==1)
								{
									foreach($rows as $r)
										{
											$info=array("idusers"=>$r->idusers,"user"=>$r->name,"level"=>$r->level);
											$this->session->set_userdata($info);
									
										}
										$data=array("name"=>$info["user"],"level"=>$info["level"],"id"=>$info["idusers"]);
//enter page CMS	
									//$this->load->view("loging_trasition",$data);
									//TEST
										$this->load->view("loging_trasition",$data);
								
						
								}else//not login in
									{
										$date=array("message"=>"Your User Name or PassWord isn't correct!1")	;								
										$this->load->view("login",$date);
									}
				
							}else{ 	$date=array("message"=>"Your User Name or PassWord isn't correct!2")	;								
										$this->load->view("login",$date); }
				
								}else{$date=array("message"=>"")	;								
										$this->load->view("login",$date);}
					
								}else 
									{
//enter CMS directement
								$this->load->view("loging_trasition");
								echo $this->session->userdata("user");
									}
			
			}//function loginpro
			
			
	//logout
	
function  loginout()
	{
		$info=array("idusers"=>"","user"=>"","level"=>"");
		$this->session->unset_userdata($info);
		$this->load->view("login");
	}
	}//class
	
	

